<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登陆</title>
<link href="../css/login-box.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
<!--
if(top!=self){
	top.location=self.location;
}
//-->
</script>
</head>
<body>
	<form id="form1" method="post" action="${pageContext.request.contextPath }/admin/login.do">
		<div style="padding: 100px 0 0 250px;">
			<div id="login-box">
				<H2>登陆</H2>
				请输入您的用户名和密码：<br /> <br />
				<div id="login-box-name" style="margin-top: 20px;">用户名：</div>
				<div id="login-box-field" style="margin-top: 20px;">
					<input name="username" id="username" class="form-login" title="用户名"
						value="" size="30" maxlength="2048" />
				</div>
				<div id="login-box-name">密&nbsp;&nbsp;&nbsp;&nbsp;码：</div>
				<div id="login-box-field">
					<input name="password" id="password" type="password"
						class="form-login" title="密码" value="" size="30" maxlength="2048" />
				</div>
				<div id="divCaptcha" style="display: none;">
					<div id="login-box-name">验证码：</div>
					<div id="login-box-field">
						<input name="vCode" id="vCode" type="text" class="form-login"
							title="验证码" value="" size="6" maxlength="6" style="width: 80px;" />
						<img id="imgVCode" alt="验证码"
							src="${pageContext.request.contextPath }/admin/common/captcha.do"
							style="vertical-align: bottom;">
					</div>
				</div>
				<br /> <br /> <br /> <a href="" onclick="login();return false;"><img
					src="../images/login-btn.png" width="103" height="42"
					style="margin-left: 90px;" /></a>
					<div style="color: red;margin-top: 10px;">${msg }</div>
			</div>
		</div>
		<input type="hidden" name="redirectUrl" value="${redirectUrl}">
	</form>
</body>
<script type="text/javascript">
	function login() {
		var username = $.trim($("#username").val());
		var password = $.trim($("#password").val());
		var vCode=$.trim($("#vCode").val());
		if(username==""){
			alert("请输入用户名！");
			return false;
		}
		if(password==""){
			alert("请输入用户密码！");
			return false;
		}
		if($("#divCaptcha").css("display")!="none"&&vCode==""){
			alert("请输入验证码！");
			return false;
		}
		$("#form1").submit();
		return false;
	}
	$(function(){
		$("#form1").keydown(function(event){
			if(event.which==13){
				login();
			}
		});
		
		$("#imgVCode").click(function(){
			$(this).attr("src","${pageContext.request.contextPath }/admin/common/captcha.do?t="+new Date().getTime());
		});
		showCaptcha();
		logOut();
	});
	
	function showCaptcha(){
		$("#divCaptcha").hide();
		$.ajax({
			url:"${pageContext.request.contextPath}/admin/common/captchaSwitch.do",
			type:"get",
			data:{},
			dataType:"text",
			success:function(data){
				if(data=="true"){//开启验证码
					$("#divCaptcha").show();
				}
			}
		});
	}
	
	function logOut(){
		$.get("${pageContext.request.contextPath}/admin/ajaxLoginOut.do");
	}
	
</script>
</html>